<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>专项工程--${fns:getConfig('productName')}</title>
<link href="${ctx}/styles/tag/jq22.css" type="text/css" rel="stylesheet" />
<link href="${ctx}/static/bootstrap/2.3.1/css/docs.css" type="text/css" rel="stylesheet" />

<script src="http://nervgh.github.io/js/es5-shim.min.js"></script>
<script src="http://nervgh.github.io/js/es5-sham.min.js"></script>
<script src="${ctx}/js/uploadJs/console-sham.min.js"></script>

<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

<!--<script src="../bower_components/angular/angular.js"></script>-->
<script src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
<script src="${ctx}/js/uploadJs/angular-file-upload.min.js"></script>
<script src="${ctx}/js/uploadJs/controllers.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	wordCountTag('contentDesc');
	wordCountTag('contentWord');
	$("#inputForm").validate({
		rules: {
			projectName:{
				maxlength:50,
			},
			advanceTime:{
				number:true,
				min:0
			}
		},
		messages: {
			codeId: {remote: "该编号已存在,换一个编号试试~"},
		},
		submitHandler:function(form){
			$.jBox.confirm("保存之后信息将不能被修改，是否确认保存？", '系统提示', function(v, h, f) {
				if (v == 'ok') {
					if($('#myTags a').length <=0){
						$.jBox.tip("请至少添加一个数据要求", 'error');
						setTimeout("$.jBox.closeTip()", 2000);
					} else{
						var dataTab ="";
						//将标签转换成json字符串保存到数据库
						$('#myTags a').each(function(){
							dataTab += $(this).attr('title')+";";
						});
						dataTab = dataTab.substring(0,dataTab.length-1);
						$('#dataTab').val(dataTab);
						sub();
// 	 		 			form.submit();
					}

				}
			}, {
				buttonsFocus : 1
			});

		},
		errorContainer: "#messageBox",
		errorPlacement: function(error, element) {
			$("#messageBox").text("输入有误，请先更正。");
			if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
				error.appendTo(element.parent().parent());
			} else {
				error.insertAfter(element);
			}
		}
	});
});
function sub(){
		var formData = new FormData($("#inputForm"));
		console.log(formData);
 		var AjaxURL = appConfig.contPath + "/specialProject/save.do";
 		 $.ajax({    
             type:'post',        
             url:AjaxURL,    
             data:$("#inputForm").serialize(),    
             cache:false,    
             dataType:'json',    
             success:function(data){   
            	 $('#projectId').val(data.id);
                	//基础数据提交成功之后再提交文件
                fileSub();
             }    
         });    
}

function  fileSub(){
	if($('.table tbody tr').length == 0){
		var url = $('#reUrl').val();
        window.location.href = url;
	} else {
		$('#btn').trigger('click');
	}
}

</script>
<style>
.control-group{
	float:left;
}
select{
	width:220px;
}
 .my-drop-zone { border: dotted 3px lightgray; }
 .nv-file-over { border: dotted 3px red; } /* Default class applied to drop zones on over */
 .another-file-over-class { border: dotted 3px green; }
.row{
	margin-left:10px !important;
}
 html, body { height: 100%; }
 textarea{
 padding:5px;
 }
 .control-group{
 margin-top:0px !important;
 }
</style>
</head>
<body >
<ul class="nav nav-tabs" style="margin: 0 4px; margin-bottom: 4px;">
		<li >
			<a href="${ctx}/specialProject/listInfo.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}">
				<i class="icon icon-list"></i>&nbsp;<span>专项工程列表</span>
			</a>
		</li>
		<sec:authorize ifAnyGranted="ROLE_sys_user_edit"></sec:authorize>
		<li class="active">
			<a href="${ctx}/specialProject/input.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}">
				<i class="icon icon-edit"></i>&nbsp;<span>新增专项工程</span>
			</a>
	 	</li>
	</ul>
	<input type="hidden" name="reUrl" id="reUrl" value="${ctx}/specialProject/listInfo.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}">
	
	<form id="inputForm" action="${ctx}/specialProject/save.do?left=${fns:encodeParamUrl(left)}&top=${fns:encodeParamUrl(top)}&parentId=${fns:encodeParamUrl(parentId)}&LId=${fns:encodeParamUrl(LId)}"
		method="post"  class="form-horizontal m">
 		<input type="hidden" name="token" value="${token}">
		<input type="hidden" name="id" id="projectId" value="" />
		<input type="hidden" name="dataTab" id ="dataTab" value="${specialProject.dataTab}" />
		<input type="hidden" name="status" id ="status" value="0" />
		<tags:message content="${msg}" />
		<fieldset>
    			<legend>基本信息</legend>
				<div class="control-group">
					<label class=" control-label">项目名称<font style="color:red;">*</font>:</label>
					<div class="controls">
					  <input class=" required" id="projectName" name="projectName"
							type="text" value="${specialProject.projectName}">
					</div>
				</div>
				<div class="control-group">
					<label class=" control-label">截止时间<font style="color:red;">*</font>:</label>
					<div class="controls">
					  <input  id="endTime" name="endTime" value="${specialProject.endTime}" 
										onclick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" class="Wdate required" type="text">
					</div>
				</div>
				<div class="control-group" >
					<label class=" control-label">提前预警时间（h）<font style="color:red;">*</font>:</label>
					<div class="controls">
					 <input  id="advanceTime" name="advanceTime"
							type="text" value="${specialProject.advanceTime}" class="required">
					</div>
				</div>
<!-- 				<div class="control-group"> -->
<!-- 					<label class=" control-label">预警频率:</label> -->
<!-- 					<div class="controls"> -->
<%-- 					 	<pt:code category="6008" name="frequency" hasEmpty="false"  default="${specialProject.frequency}"></pt:code> --%>
<!-- 					</div> -->
<!-- 				</div> -->
				<div class="control-group" style="clear:both">
					<label class=" control-label">工程描述:</label>
					<div class="controls">
					<div class="wordCount wyInline" id="contentDesc">
						<textarea placeholder="" rows='3' id="projectDesc" name="projectDesc">${specialProject.projectDesc}</textarea>
						<span class="wordwrap"><var class="word">2000</var>/2000</span>
					</div>
					</div>
				</div>
				<div class="control-group" style="clear:both">
					<label class=" control-label">备注:</label>
					<div class="controls">
						<div class="wordCount wyInline" id="contentWord">
							<textarea placeholder="" rows='1' style="height:40px" id="remark" name="remark">${specialProject.remark}</textarea>
							<span class="wordwrap"><var class="word">200</var>/200</span>
						</div>
					</div>
				</div>
				<div class="plus-tag tagbtn clearfix" id="myTags" style="clear:both;margin-left:180px;">
<%-- 					<c:forEach items="${specialProject.tabList}" var="tab"> --%>
<%-- 						<a value="-1" title="${tab}" href="javascript:void(0);"><span>${tab}</span><em></em></a> --%>
<%-- 					</c:forEach> --%>
				</div>
				<div class="control-group">
					<label class=" control-label">专项数据:</label>
					<div class="controls">
					<div class="plus-tag-add">
							<ul class="Form FancyForm">
								<li><input id="" name="" type="text" class="stext" maxlength="20"  style="float:left;margin-right:10px;"/>
									<button type="button" class="Button RedButton Button18"
										style="font-size: 14px;margin-right:15px;">添加</button>
										<span style="line-height:29px;">(<span style='color:red'>提示</span>：最多只能添加10个标签)</span>
								</li>
							</ul>
					</div>
					<!--plus-tag-add end-->
					
				</div>
				</div>
				<div class="control-group" style="clear:both">
					<label class=" control-label">相关附件:</label>
					<div class="controls" id="ng-app" ng-app="app">
					
						<div class="container" ng-controller="AppController" nv-file-drop="" uploader="uploader" filters="queueLimit, customFilter">
				            <div class="row">
				                <div class="col-md-9" style="margin-bottom: 40px">
									<div class="col-md-3">
					                    <input type="file" nv-file-select="" uploader="uploader" multiple   style="margin-right:180px"/>
					                      <span>文件数: <span style="color: #64BB6C;font-weight: bold;font-size: 18px;">{{ uploader.queue.length }}</span></span>
<!-- 					                      <input id="btnCancel" class="btn" type="button" value="返 回" onclick="fileSub()" /> -->
					                </div>
				                    <table class="table" style="width:70%;">
				                        <thead>
				                            <tr>
				                                <th width="50%">文件名</th>
				                                <th ng-show="uploader.isHTML5">大小</th>
				                                <th>操作</th>
				                            </tr>
				                        </thead>
				                        <tbody>
				                            <tr ng-repeat="item in uploader.queue">
				                                <td><strong>{{ item.file.name }}</strong></td>
				                                <td ng-show="uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
				                                <td nowrap>
				                                    <button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
				                                        <span class="glyphicon glyphicon-trash"></span>删除
				                                    </button>
				                                </td>
				                            </tr>
				                        </tbody>
				                    </table>
				                     <button id="btn" style="display:none" type="button" class="btn btn-success btn-s" ng-click="uploader.uploadAll()" ng-disabled="!uploader.getNotUploadedItems().length">
			                            <span class="glyphicon glyphicon-upload"></span> Upload all
			                        </button>
				                </div>
				            </div>
				        </div>
					</div>
				</div>
		</fieldset>
		
      <div class="form-actions" style="text-align:center;padding-left:0px;">
				<input id="btnSubmit" class="btn btn-primary" type="submit"
					value="保 存" />
					&nbsp; &nbsp;&nbsp;&nbsp;
<input id="btnCancel" class="btn" type="button" value="返 回" onclick="JavaScript:history.go(-1);" />
	 </div>
	</form>
	
	<script type="text/javascript" src="${ctx}/js/jqTag.js"></script>
</body>
</html>
